local sk__huangyin = fk.CreateSkill {

  name = "sk__huangyin",

  tags = {  },

}



sk__huangyin:addEffect(fk.AfterCardsMove, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(sk__huangyin.name) then
      for _, move in ipairs(data) do
        if move.moveReason == fk.ReasonDiscard then
          if move.from and move.from ~= player and move.proposer and move.proposer == player then
            for _, info in ipairs(move.moveInfo) do
              if (info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip) and
                table.contains(player.room.discard_pile, info.cardId) then
                return true
              end
            end
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = {}
    for _, move in ipairs(data) do
      if move.moveReason == fk.ReasonDiscard then
        if move.from and move.from ~= player and move.proposer and move.proposer == player then
          for _, info in ipairs(move.moveInfo) do
            if (info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip) and
              table.contains(room.discard_pile, info.cardId) then
              table.insertIfNeed(cards, info.cardId)
            end
          end
        end
      end
    end
    room:moveCardTo(table.random(cards), Card.PlayerHand, player, fk.ReasonJustMove, sk__huangyin.name, nil, true, player)
  end,
})

return sk__huangyin